/*
 *
 * Copyright (c) 2020 The Raptor Authors. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

#include "src/surface/container.h"
#include "raptor-lite/impl/config.h"
#include "raptor-lite/impl/handler.h"
#include "raptor-lite/impl/property.h"
#ifdef _WIN32
#include "src/windows/container_impl.h"
#else
#include "src/linux/container_impl.h"
#endif

namespace raptor {

ContainerAdaptor::ContainerAdaptor(struct Option *option)
    : _impl(new ContainerImpl(option)) {}

ContainerAdaptor::~ContainerAdaptor() { delete _impl; }

#ifdef _WIN32
raptor_error ContainerAdaptor::Init(PollingThread *pt) { return _impl->Init(pt); }
#else
raptor_error ContainerAdaptor::Init() { return _impl->Init(); }
#endif

raptor_error ContainerAdaptor::Start() { return _impl->Start(); }
void ContainerAdaptor::Shutdown() { _impl->Shutdown(); }

raptor_error ContainerAdaptor::AttachEndpoint(Endpoint ep) { return _impl->AttachEndpoint(ep); }

bool ContainerAdaptor::SendMsg(uint32_t connection_id, const Slice &s) {
    if (s.empty()) return true;
    return _impl->SendMsg(connection_id, s);
}

void ContainerAdaptor::CloseEndpoint(Endpoint ep, bool notify) { _impl->CloseEndpoint(ep, notify); }

} // namespace raptor
